#include "lsp.h"
#include <unistd.h>

int main(int argc, char** argv) 
{
	int port = 8016;
	char * ip = "127.0.0.1";
	if(argc > 1)
		port = atoi(argv[1]);
	if(argc > 2)
		ip = (argv[2]);
	//printf("before create\n");
	lsp_client* myclient = lsp_client_create(ip, port);
	//printf("after create\n");
	//after create
	char message[] = "ilovethiscoursealready";

	lsp_client_write(myclient, (uint8_t *) message, strlen(message));
	//sleep(20);
	uint8_t buffer[4096];
	int bytes_read = lsp_client_read(myclient, (uint8_t *) buffer);
	//printf("after read\n");
	puts((const char *)buffer);

	lsp_client_write(myclient, (uint8_t *) message, strlen(message));
	
	puts((const char *)buffer);
	//printf("%s\n", buffer);
	lsp_client_close(myclient);
	
	printf("End of client code\n");
	return 0;
}
